<?php
    // 汇率
    function updateSalesCurrency($now_month) {
        $url  = 'http://www.chinamoney.com.cn/ags/ms/cm-u-bk-ccpr/CcprHisNew';
        $date = $now_month.'-01';
        $now_url = $url."?startDate={$date}&endDate={$date}";
        $return  = file_get_contents($now_url);
        if(!$return) {
            // 取最新汇率
            $new_url = $url.'?pageNum=1&pageSize=1';
            $return  = file_get_contents($new_url);
        }

        if($return) {
            $ret = json_decode($return,true);
            if(!empty($ret) && !$ret['data']['flagMessage'] && isset($ret['records'][0]['values'])) {
                $srarch_list = $ret['data']['head'];
                $values      = $ret['records'][0]['values'];
                $data_list   = array_combine($srarch_list,$values);
                return $data_list;
            }
        }
        return true;
    }
?>